<div class="row head">
    <div class="col-lg-12">
        <?php if(validation_errors()): ?>
            <div class="alert alert-error" style="margin: 10px 10px 10px 0px;">
              <button data-dismiss="alert" class="close" type="button">×</button>
              <?php echo validation_errors(); ?>
            </div>
        <?php endif;?>
        <?php if(@$data == 201):?>
            <div class="alert alert-error" style="margin: 10px 10px 10px 0px;">
              <button data-dismiss="alert" class="close" type="button">×</button>
              <span>Kênh đã tồn tại. Thêm thất bại!</span>
            </div>
        <?php endif;?>
        <h1 class="page-header">Thêm kênh</h1>
    </div>
    <!-- /.col-lg-12 -->
</div>
<div class="row">
    <div class="col-lg-12">
        <div class="panel-body">
            <div class="row">
                <div class="col-lg-6">
                    <?php echo form_open()?>
                        <div class="form-group">
                            <label>Tên kênh</label>
                            <input id="channel" name="channel" class="form-control" placeholder="Nhập tên kênh"/>
                        </div>
                        <div class="form-group logo-show">
                            <label style="margin-right: 20px">Logo kênh</label>
                            <div style="position: relative;display:inline-block">
                                <img src="" id="show_logo_" style="display: inline-block; vertical-align: middle;width: 282px;height: 88px;border: 1px solid #CCC;background: #CCC" />
                                <input class="image-input" type="file" name="img_uploads" id="logo" onchange="convertimage('logo', 'logo_channel_', 'show_logo_');" value="" />
                                <label class="hidden-label" for="logo"></label>
                                <input type="hidden" name="logo_channel_" id="logo_channel_" value="" />
                            </div>
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn btn-primary">Thêm</button>
                        </div>
                    </form>
                </div>
                <!-- /.col-lg-6 (nested) -->
            </div>
            <!-- /.row (nested) -->
        </div>
        <!-- /.panel-body -->
    </div>
    <!-- /.col-lg-12 -->
</div>

<script>

function convertimage(id, id_parse, img_show)
{
    var id = id;
    var id_parse = id_parse;
    var img_show = img_show;
    var filesSelected = document.getElementById(id).files;
    if (filesSelected.length > 0)
    {
        var fileToLoad = filesSelected[0];

        var fileReader = new FileReader();

        fileReader.onload = function(fileLoadedEvent) 
        {
            $("#"+id_parse).attr('value', fileLoadedEvent.target.result);
            $("#"+id_parse+"check").val('1');
            $("#"+img_show).attr('src', fileLoadedEvent.target.result);
        };

        fileReader.readAsDataURL(fileToLoad);
    }
}

</script>